package com.by.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TokenValidIntercepor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String token=request.getHeader("token");
        response.setContentType("applcation/json;charset=utf-8");
        if(null==token){
            response.getWriter().write("没有token！");
            return false;
        }

        //验证token
        return true;
    }
}